/*
 * @Descripttion:
 * @version:
 * @Author: kl2018
 * @Date: 2020-03-17 09:11:31
 * @LastEditors: kl2018
 * @LastEditTime: 2020-06-22 13:50:21
 */
import { action, observable } from 'mobx';
import { message } from 'antd';
import { WeaLocaleProvider } from 'ecCom';
import * as Api from '../apis/trackingWorkflowApi';

const { getLabel } = WeaLocaleProvider;

export default class TrackingWorkflowStore {
  @observable processOpinionVisible = false;
  @observable opinionList = [];

  @action.bound
  onCancelTrack(keys, clear, getData) {
    const params = {
      requestid: keys.join(','),
    };
    Api.removeTracksReq(params).then((data) => {
      if (data.api_status) {
        message.success(getLabel('129248', '取消成功'));
        clear && clear();
        getData();
      }
    });
  }

  @action.bound
  processOpinion(requestid, workflowid) {
    const params = {
      requestid,
      workflowid,
    };
    Api.getCirculationOpinions(params).then((data) => {
      if (data.loglist) {
        this.opinionList = data.loglist;
        this.processOpinionVisible = true;
      }
    });
  }

  @action.bound
  processOpinionHide() {
    this.processOpinionVisible = false;
  }
}
